﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using KorbeRTR.Utility;
using KorbeRTR.Models;

namespace KorbeRTR
{
    public partial class Form自动添加设定 : Form
    {
        private Models.OmronData plc => FormMainWindow.OmronPLC;

        private const double MinAH = 0;
        private const double MaxAH = 100000;

        private const double MinArea = 0;
        private const double MaxArea = 9999;

        public Form自动添加设定()
        {
            InitializeComponent();

            UpdateAll();
        }

        private void Form自动添加设定_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void UpdateAll()
        {
            UpdateContent();
            UpdateSwitchStatus();
        }

        private void UpdateSwitchStatus()
        {
            if (!plc.P平整剂.开关.IsWrited) hslP平整剂开关.SwitchStatus = plc.P平整剂.开关.Value != 0;
            if (!plc.P平整剂.模式.IsWrited) hslP平整剂模式.SwitchStatus = plc.P平整剂.模式.Value != 0;

            if (!plc.G光泽剂.开关.IsWrited) hslG光泽剂开关.SwitchStatus = plc.G光泽剂.开关.Value != 0;
            if (!plc.G光泽剂.模式.IsWrited) hslG光泽剂模式.SwitchStatus = plc.G光泽剂.模式.Value != 0;

            if (!plc.S湿润剂.开关.IsWrited) hslS湿润剂开关.SwitchStatus = plc.S湿润剂.开关.Value != 0;
            if (!plc.S湿润剂.模式.IsWrited) hslS湿润剂模式.SwitchStatus = plc.S湿润剂.模式.Value != 0;

            if (!plc.SXQJ酸性清洁.开关.IsWrited) hslSXQJ开关.SwitchStatus = plc.SXQJ酸性清洁.开关.Value != 0;
            if (!plc.SXQJ酸性清洁.模式.IsWrited) hslSXQJ模式.SwitchStatus = plc.SXQJ酸性清洁.模式.Value != 0;

            if (!plc.W微蚀.开关.IsWrited) hslWS开关.SwitchStatus = plc.W微蚀.开关.Value != 0;
            if (!plc.W微蚀.模式.IsWrited) hslWS模式.SwitchStatus = plc.W微蚀.模式.Value != 0;

            if (!plc.SJ酸浸.开关.IsWrited) hslSJ开关.SwitchStatus = plc.SJ酸浸.开关.Value != 0;
            if (!plc.SJ酸浸.模式.IsWrited) hslSJ模式.SwitchStatus = plc.SJ酸浸.模式.Value != 0;

            if (!plc.SX酸洗.开关.IsWrited) hslSX开关.SwitchStatus = plc.SX酸洗.开关.Value != 0;
            if (!plc.SX酸洗.模式.IsWrited) hslSX模式.SwitchStatus = plc.SX酸洗.模式.Value != 0;

            if (!plc.K抗氧化.开关.IsWrited) hslKYH开关.SwitchStatus = plc.K抗氧化.开关.Value != 0;
            if (!plc.K抗氧化.模式.IsWrited) hslKYH模式.SwitchStatus = plc.K抗氧化.模式.Value != 0;

            if (!plc.TF铜粉添加.开关.IsWrited) hslT铜粉添加开关.SwitchStatus = plc.TF铜粉添加.开关.Value != 0;
            if (!plc.TF铜粉添加.模式.IsWrited) hslT铜粉添加模式.SwitchStatus = plc.TF铜粉添加.模式.Value != 0;
        }

        private void UpdateContent()
        {
            {   // 平整剂
                txtP平整剂设定AH.Text = plc.P平整剂.设定.Value.ToString();
                txtP平整剂手动添加杯数.Text = plc.P平整剂.添加杯数设定.Value.ToString();
                txtP平整剂实际AH.Text = plc.P平整剂.实际.Value.ToString();
                txtP平整剂剩余杯数.Text = plc.P平整剂.添加剩余杯数.Value.ToString();
                txtP平整剂累计AH.Text = plc.P平整剂.累计.Value.ToString();
                txtP平整剂状态.Text = (plc.P平整剂.状态.Value != 0) ? "运行" : "停止";
                txtP平整剂异常.Text = (plc.P平整剂.异常.Value != 0) ? "异常" : "";

            }

            {   // 光泽剂
                txtG光泽剂设定AH.Text = plc.G光泽剂.设定.Value.ToString();
                txtG光泽剂手动添加杯数.Text = plc.G光泽剂.添加杯数设定.Value.ToString();
                txtG光泽剂实际AH.Text = plc.G光泽剂.实际.Value.ToString();
                txtG光泽剂剩余杯数.Text = plc.G光泽剂.添加剩余杯数.Value.ToString();
                txtG光泽剂累计AH.Text = plc.G光泽剂.累计.Value.ToString();
                txtG光泽剂状态.Text = (plc.G光泽剂.状态.Value != 0) ? "运行" : "停止";
                txtG光泽剂异常.Text = (plc.P平整剂.异常.Value != 0) ? "异常" : "";

              
            }

            {   // 湿润剂
                txtS湿润剂设定AH.Text = plc.S湿润剂.设定.Value.ToString();
                txtS湿润剂手动添加杯数.Text = plc.S湿润剂.添加杯数设定.Value.ToString();
                txtS湿润剂实际AH.Text = plc.S湿润剂.实际.Value.ToString();
                txtS湿润剂剩余杯数.Text = plc.S湿润剂.添加剩余杯数.Value.ToString();
                txtS湿润剂累计AH.Text = plc.S湿润剂.累计.Value.ToString();
                txtS湿润剂状态.Text = (plc.S湿润剂.状态.Value != 0) ? "运行" : "停止";
                txtS湿润剂异常.Text = (plc.S湿润剂.异常.Value != 0) ? "异常" : "";

              
            }

            {   // 酸性清洁
                txtSXQJ设定AH.Text = plc.SXQJ酸性清洁.设定.Value.ToString();
                txtSXQJ手动添加杯数.Text = plc.SXQJ酸性清洁.添加杯数设定.Value.ToString();
                txtSXQJ实际AH.Text = plc.SXQJ酸性清洁.实际.Value.ToString();
                txtSXQJ剩余杯数.Text = plc.SXQJ酸性清洁.添加剩余杯数.Value.ToString();
                txtSXQJ累计AH.Text = plc.SXQJ酸性清洁.累计.Value.ToString();
                txtSXQJ状态.Text = (plc.SXQJ酸性清洁.状态.Value != 0) ? "运行" : "停止";
                txtSXQJ异常.Text = (plc.SXQJ酸性清洁.异常.Value != 0) ? "异常" : "";

            }

            {   // 微蚀
                txtWS设定AH.Text = plc.W微蚀.设定.Value.ToString();
                txtWS手动添加杯数.Text = plc.W微蚀.添加杯数设定.Value.ToString();
                txtWS实际AH.Text = plc.W微蚀.实际.Value.ToString();
                txtWS剩余杯数.Text = plc.W微蚀.添加剩余杯数.Value.ToString();
                txtWS累计AH.Text = plc.W微蚀.累计.Value.ToString();
                txtWS状态.Text = (plc.W微蚀.状态.Value != 0) ? "运行" : "停止";
                txtWS异常.Text = (plc.W微蚀.异常.Value != 0) ? "异常" : "";

            }

            {   // 酸浸
                txtSJ设定AH.Text = plc.SJ酸浸.设定.Value.ToString();
                txtSJ手动添加杯数.Text = plc.SJ酸浸.添加杯数设定.Value.ToString();
                txtSJ实际AH.Text = plc.SJ酸浸.实际.Value.ToString();
                txtSJ剩余杯数.Text = plc.SJ酸浸.添加剩余杯数.Value.ToString();
                txtSJ累计AH.Text = plc.SJ酸浸.累计.Value.ToString();
                txtSJ状态.Text = (plc.SJ酸浸.状态.Value != 0) ? "运行" : "停止";
                txtSJ异常.Text = (plc.SJ酸浸.异常.Value != 0) ? "异常" : "";

            }

            {   // 酸洗
                txtSX设定AH.Text = plc.SX酸洗.设定.Value.ToString();
                txtSX手动添加杯数.Text = plc.SX酸洗.添加杯数设定.Value.ToString();
                txtSX实际AH.Text = plc.SX酸洗.实际.Value.ToString();
                txtSX剩余杯数.Text = plc.SX酸洗.添加剩余杯数.Value.ToString();
                txtSX累计AH.Text = plc.SX酸洗.累计.Value.ToString();
                txtSX状态.Text = (plc.SX酸洗.状态.Value != 0) ? "运行" : "停止";
                txtSX异常.Text = (plc.SX酸洗.异常.Value != 0) ? "异常" : "";

            }
            {   // 抗氧化
                txtKYH设定AH.Text = plc.K抗氧化.设定.Value.ToString();
                txtKYH手动添加杯数.Text = plc.K抗氧化.添加杯数设定.Value.ToString();
                txtKYH实际AH.Text = plc.K抗氧化.实际.Value.ToString();
                txtKYH剩余杯数.Text = plc.K抗氧化.添加剩余杯数.Value.ToString();
                txtKYH累计AH.Text = plc.K抗氧化.累计.Value.ToString();
                txtKYH状态.Text = (plc.K抗氧化.状态.Value != 0) ? "运行" : "停止";
                txtKYH异常.Text = (plc.K抗氧化.异常.Value != 0) ? "异常" : "";

            }

            {   // 铜粉添加
                txtT铜粉添加设定AH.Text = plc.TF铜粉添加.设定.Value.ToString();
                txtT铜粉添加手动添加杯数.Text = plc.TF铜粉添加.添加杯数设定.Value.ToString();
                txtT铜粉添加实际AH.Text = plc.TF铜粉添加.实际.Value.ToString();
                txtT铜粉添加剩余杯数.Text = plc.TF铜粉添加.添加剩余杯数.Value.ToString();
                txtT铜粉添加累计AH.Text = plc.TF铜粉添加.累计.Value.ToString();
                txtT铜粉添加状态.Text = (plc.TF铜粉添加.状态.Value != 0) ? "运行" : "停止";
                txtT铜粉添加异常.Text = (plc.TF铜粉添加.异常.Value != 0) ? "异常" : "";

            }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            UpdateContent();
        }

        private void btn刷新_Click(object sender, EventArgs e)
        {
            UpdateAll();
        }

        #region 平整剂
        private void hslP平整剂开关_Click(object arg1, EventArgs arg2)
        {
            plc.P平整剂.开关.Value = plc.P平整剂.开关.Value.Alt();
        }

        private void hslP平整剂模式_Click(object sender, EventArgs e)
        {
            plc.P平整剂.模式.Value = plc.P平整剂.模式.Value.Alt();
        }

        private void btnP平整剂设定AH_Click(object sender, EventArgs e)
        {
            string name = "平整剂设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.P平整剂.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnP平整剂手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "平整剂手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.P平整剂.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnP平整剂累计AH_Click(object sender, EventArgs e)
        {
            if(!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.P平整剂.累计.Value = 0;
        }
        #endregion

        #region 光泽剂
        private void hslG光泽剂开关_Click(object arg1, EventArgs arg2)
        {
            plc.G光泽剂.开关.Value = plc.G光泽剂.开关.Value.Alt();
        }

        private void hslG光泽剂模式_Click(object arg1, EventArgs arg2)
        {
            plc.G光泽剂.模式.Value = plc.G光泽剂.模式.Value.Alt();
        }

        private void btnG光泽剂设定AH_Click(object sender, EventArgs e)
        {
            string name = "光泽剂设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.G光泽剂.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnG光泽剂手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "光泽剂手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.G光泽剂.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnG光泽剂累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.G光泽剂.累计.Value = 0;
        }

        #endregion

        #region 湿润剂
        private void hslS湿润剂开关_Click(object arg1, EventArgs arg2)
        {
            plc.S湿润剂.开关.Value = plc.S湿润剂.开关.Value.Alt();
        }

        private void hslS湿润剂模式_Click(object arg1, EventArgs arg2)
        {
            plc.S湿润剂.模式.Value = plc.S湿润剂.模式.Value.Alt();
        }

        private void btnS湿润剂设定AH_Click(object sender, EventArgs e)
        {
            string name = "湿润剂设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.S湿润剂.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnS湿润剂手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "湿润剂手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.S湿润剂.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnS湿润剂累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.S湿润剂.累计.Value = 0;
        }

        #endregion



 

        #region 酸性清洁
        private void btnSXQJ设定AH_Click(object sender, EventArgs e)
        {
            string name = "酸性清洁设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SXQJ酸性清洁.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSXQJ手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "酸性清洁手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SXQJ酸性清洁.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSXQJ累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.SXQJ酸性清洁.累计.Value = 0;
        }

        private void hslSXQJ开关_Click(object sender, EventArgs e)
        {
            plc.SXQJ酸性清洁.开关.Value = plc.SXQJ酸性清洁.开关.Value.Alt();
        }

        private void hslSXQJ模式_Click(object sender, EventArgs e)
        {
            plc.SXQJ酸性清洁.模式.Value = plc.SXQJ酸性清洁.模式.Value.Alt();
        }
        #endregion

        #region 微蚀      

        private void btnWS设定AH_Click(object sender, EventArgs e)
        {
            string name = "微蚀设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.W微蚀.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnWS手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "微蚀手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.W微蚀.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnWS累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.W微蚀.累计.Value = 0;
        }

        private void hslWS开关_Click(object sender, EventArgs e)
        {
            plc.W微蚀.开关.Value = plc.W微蚀.开关.Value.Alt();
        }

        private void hslWS模式_Click(object sender, EventArgs e)
        {
            plc.W微蚀.模式.Value = plc.W微蚀.模式.Value.Alt();
        }
        #endregion

        #region 酸浸
        private void btnSJ设定AH_Click(object sender, EventArgs e)
        {
            string name = "酸浸设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SJ酸浸.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSJ手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "酸浸手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SJ酸浸.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSJ累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.SJ酸浸.累计.Value = 0;
        }

        private void hslSJ开关_Click(object sender, EventArgs e)
        {
            plc.SJ酸浸.开关.Value = plc.SJ酸浸.开关.Value.Alt();
        }

        private void hslSJ模式_Click(object sender, EventArgs e)
        {
            plc.SJ酸浸.模式.Value = plc.SJ酸浸.模式.Value.Alt();
        }
        #endregion

        #region 酸洗
        private void btnSX设定AH_Click(object sender, EventArgs e)
        {
            string name = "酸洗设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SX酸洗.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSX手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "酸洗手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.SX酸洗.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnSX累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.SX酸洗.累计.Value = 0;
        }

        private void hslSX开关_Click(object sender, EventArgs e)
        {
            plc.SX酸洗.开关.Value = plc.SX酸洗.开关.Value.Alt();
        }

        private void hslSX模式_Click(object sender, EventArgs e)
        {
            plc.SX酸洗.模式.Value = plc.SX酸洗.模式.Value.Alt();
        }
        #endregion

        #region 抗氧化
        private void btnKYH设定AH_Click(object sender, EventArgs e)
        {
            string name = "抗氧化设定AH";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.K抗氧化.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnKYH手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "抗氧化手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.K抗氧化.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnKYH累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.K抗氧化.累计.Value = 0;
        }

        private void hslKYH开关_Click(object sender, EventArgs e)
        {
            plc.K抗氧化.开关.Value = plc.K抗氧化.开关.Value.Alt();
        }

        private void hslKYH模式_Click(object sender, EventArgs e)
        {
            plc.K抗氧化.模式.Value = plc.K抗氧化.模式.Value.Alt();
        }
        #endregion

        #region 铜粉添加
        private void hslT铜粉添加开关_Click(object arg1, EventArgs arg2)
        {
            plc.TF铜粉添加.开关.Value = plc.TF铜粉添加.开关.Value.Alt();
        }

        private void hslT铜粉添加模式_Click(object arg1, EventArgs arg2)
        {
            plc.TF铜粉添加.模式.Value = plc.TF铜粉添加.模式.Value.Alt();
        }

        private void btnT铜粉添加设定AH_Click(object sender, EventArgs e)
        {
            string name = "铜粉设定杯数";
            string type = "";
            string unit = "";
            double min = MinAH;
            double max = MaxAH;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.TF铜粉添加.设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnT铜粉添加手动添加杯数_Click(object sender, EventArgs e)
        {
            string name = "铜粉手动添加杯数";
            string type = "";
            string unit = "";
            double min = 0;
            double max = 9999;

            string msg = string.Format("请输入'{0}'{1}:\n(范围:{2}-{3},单位:{4})", name, type, min, max, unit);

            FormInfo formInfo = new FormInfo(msg, min, max);

            formInfo.ShowDialog();
            if (formInfo.ok)
            {
                plc.TF铜粉添加.添加杯数设定.Value = formInfo.input.ToDouble();
            }
        }

        private void btnT铜粉添加累计AH_Click(object sender, EventArgs e)
        {
            if (!Global.GetInstance().CurrentUser.Check累计值清零权限())
            {
                MessageBox.Show("无累计值清零权限");
                return;
            }

            plc.TF铜粉添加.累计.Value = 0;
        }

        #endregion
    }

    public static partial class KorbeVCPExtersions
    {
        public static UInt16 Alt(this UInt16 x)
        {
            return (UInt16)((0 == x)? 1 : 0);
        }
    }
}
